<template>
  <!--注册审核-->
    <div class="AuditRegister">


      <div class="title">
        注册审核
      </div>
      <!--详情窗口-->
      <el-dialog top="200vh" class="showDialog" customClass="customWidth" fullscreen="true" title="详情" :visible.sync="showCheckDialog">
        <el-descriptions class="margin-top" title="企业资质信息" :column="3">
          <el-descriptions-item label="企业名称">{{showForm.supplierName}}</el-descriptions-item>
          <el-descriptions-item label="企业类型">{{showForm.enterpriseType=='0'?'买方':'卖方'}}</el-descriptions-item>
          <el-descriptions-item label="法定代表人">{{showForm.legalPerson}}</el-descriptions-item>
          <el-descriptions-item label="法人身份证">{{showForm.legalPersonIdNumber}}</el-descriptions-item>
          <el-descriptions-item label="注册地区">{{showForm.registrationArea}}</el-descriptions-item>
          <el-descriptions-item label="企业邮箱">{{showForm.enterpriseMailbox}}</el-descriptions-item>
          <el-descriptions-item label="联系电话">{{showForm.contactNumber}}</el-descriptions-item>
          <el-descriptions-item label="传真">{{showForm.fax}}</el-descriptions-item>
          <el-descriptions-item label="邮政编码">{{showForm.postalCode}}</el-descriptions-item>

          <el-descriptions-item label="注册资金（万元）">{{showForm.registerFund}}</el-descriptions-item>
          <el-descriptions-item label="营业执照号">{{showForm.businessCertificateId}}</el-descriptions-item>
          <el-descriptions-item label="组织机构代码">{{showForm.organizationCode}}</el-descriptions-item>
          <el-descriptions-item label="经营许可证编号">{{showForm.businessLicenseId}}</el-descriptions-item>

          <el-descriptions-item label="税务登记证代码">{{showForm.taxRegistrationCertificateCode}}</el-descriptions-item>
          <el-descriptions-item label="开户银行">{{showForm.bankOfDeposit}}</el-descriptions-item>
          <el-descriptions-item label="账号">{{showForm.legal_person}}</el-descriptions-item>
          <el-descriptions-item :span="3" label="煤源存放地点、数量、质量">{{showForm.coalDescription}}</el-descriptions-item>

          <el-descriptions-item :span="3" label="运输方式及保障能力">{{showForm.typeOfShipping}}</el-descriptions-item>
          <el-descriptions-item :span="3" label="应商介绍">{{showForm.introductionToYingshang}}</el-descriptions-item>
          <el-descriptions-item label="企业资料">
            <span style="display:inline-block;margin-left:20px">
              <span style="display:block;text-align: center;">营业执照</span>
              <el-image
                style="width: 100px; height: 100px"
                :src="showForm.taxRegiSrtificate"
              ></el-image>
            </span>
            <span style="display:inline-block;margin-left:20px">
              <span style="display:block;text-align: center;">税务登记证</span>
              <el-image
                style="width: 100px; height: 100px"
                :src="showForm.taxRegiSrtificate"
              ></el-image>
            </span>
            <span style="display:inline-block;margin-left:20px">
              <span style="display:block;text-align: center;">组织机构代码证</span>
              <el-image
                style="width: 100px; height: 100px"
                :src="showForm.organCodeCertificate"
              ></el-image>
            </span>
            <span style="display:inline-block;margin-left:20px">
              <span style="display:block;text-align: center;">开户许可证</span>
              <el-image
                style="width: 100px; height: 100px"
                :src="showForm.accountOpenPermit"
              ></el-image>
            </span>
            <span style="display:inline-block;margin-left:20px">
              <span style="display:block;text-align: center;">煤炭经营许可证</span>
              <el-image
                style="width: 100px; height: 100px"
                :src="showForm.coalBuLicense"
              ></el-image>
            </span>

            <span style="display:inline-block;margin-left:20px">
              <span style="display:block;text-align: center;">法人身份证</span>
              <el-image
                style="width: 100px; height: 100px"
                :src="showForm.corporateIdCard"
              ></el-image>
            </span>



          </el-descriptions-item>
        </el-descriptions>

        <!--            <el-button size="mini" icon='el-icon-download' @click="download(showForm.taxRegiSrtificate)">营业执照</el-button>-->
        <!--            <el-button size="mini" icon='el-icon-download' @click="download(showForm.taxRegiSrtificate)">税务登记证</el-button>-->
        <!--            <el-button size="mini" icon='el-icon-download' @click="download(showForm.organCodeCertificate)">组织机构代码证</el-button>-->
        <!--            <el-button size="mini" icon='el-icon-download' @click="download(showForm.accountOpenPermit)">开户许可证</el-button>-->
        <!--            <el-button size="mini" icon='el-icon-download' @click="download(showForm.coalBuLicense)">煤炭经营许可证</el-button>-->
        <!--            <el-button size="mini" icon='el-icon-download' @click="download(showForm.corporateIdCard)">法人身份证</el-button>-->


            <el-row>
              <el-col :span="23" style="text-align: center;">
                <el-button v-if="available=='待审核'" type="primary" @click="approved('过审核')">通过审核</el-button>
                <el-button v-if="available=='待审核'" @click="approved('未过审')">驳回</el-button>
                <el-button  @click="showCheckDialog=false">关闭</el-button>
              </el-col>
            </el-row>

<!--        </el-form>-->





      </el-dialog>


      <!--头部区-->
      <div class="head">
        <el-form :inline="true" :model="form" >
          <el-form-item label="用户名">
            <el-input v-model="form.username" placeholder="请输入"></el-input>
          </el-form-item>

          <el-form-item label="选择用户类型">
            <el-select v-model="form.status" placeholder="选择用户类型">
              <el-option label="全部" value=""></el-option>
              <el-option label="买方" value="0"></el-option>
              <el-option label="卖方" value="1"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item  label="选择审核状态">
            <el-select v-model="form.available" placeholder="选择审核状态">
              <el-option label="全部" value=""></el-option>
              <el-option label="待审核" value="待审核"></el-option>
              <el-option label="未过审" value="未过审"></el-option>
              <el-option label="过审核" value="过审核"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" @click="getData">查询</el-button>
          </el-form-item>


        </el-form>
      </div>




      <!--表格区-->
      <div class="content">
        <el-table
          :data="dataList"
          stripe
          >

          <el-table-column
            label="用户id"
            prop="id">
          </el-table-column>
          <el-table-column
            prop="username"
            label="用户名">
          </el-table-column>
          <el-table-column
            prop="identity"
            label="身份证号">
          </el-table-column>
          <el-table-column
            prop="phone"
            label="手机号">
          </el-table-column>
          <el-table-column
            prop="enterpriseid"
            label="企业编号">
          </el-table-column>
          <el-table-column
            prop="address"
            label="住址">
          </el-table-column>
          <el-table-column
            prop="status"
            label="用户类型">
            <template slot-scope="scope">
              {{scope.row.status=='0'?'买方':scope.row.status=='1' ? '卖方':'未知'}}
            </template>
          </el-table-column>
          <el-table-column
            prop="available"
            label="审核状态">
            <template slot-scope="scope">
              <el-tag
                :type="scope.row.available === '过审核' ? 'success' : scope.row.available === '待审核' ?'warning':'未过审'"
                disable-transitions>{{scope.row.available}}</el-tag>
            </template>
          </el-table-column>

          <el-table-column
            label="操作">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="showDetail(scope.row)">详情</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="block">
          <el-pagination
            @current-change="handleCurrentChange"
            :current-page.sync="pagination.currentPage"
            :page-size="pagination.pageSize"
            layout="total, prev, pager, next"
            :total="pagination.totals">
          </el-pagination>
        </div>
      </div>
    </div>



</template>

<script>
  import Common from '@/components/common/Common'
  const axios=require("axios");



    export default {
        name: "AuditRegister",
      created:function(){
        if(sessionStorage.getItem("userid")==null&&sessionStorage.getItem("status")!='2'){
          this.$router.push("/login");
        }
      },
      mounted:function(){
          this.getData();
      },
      data(){
          return{
            pagination: {
              pageSize: 6, // 显示的条数
              totals: 12, // 总数
              currentPage: 1, // 当前第几页
            },
            dataList: [],
            form:{
              username:'',
              status:'',
              available:'待审核',
            },
            available:'',
            showCheckDialog:false,
            showForm:{
              enterpriseId:'',
              enterpriseType:'',
              supplierName:'',
              legalPerson:'',
              legalPersonIdNumber:'',
              registrationArea:'',
              enterpriseMailbox:'',
              contactNumber:'',
              fax:'',
              postalCode:'',
              registerFund:'',
              businessCertificateId:'',
              organizationCode:'',
              businessLicenseId:'',
              taxRegistrationCertificateCode:'',
              bankOfDeposit:'',
              accountNumber:'',
              typeOfShipping:'',
              introductionToYingshang:'',
              coalDescription:'',
              buLicense:'',
              taxRegiSrtificate:'',
              organCodeCertificate:'',
              accountOpenPermit:'',
              coalBuLicense:'',
              corporateIdCard:''
            },
          }
      },
      methods:{
        handleCurrentChange(val){
          this.pagination.currentPage=val;
          this.getData();
        },
        getData(){
          var vm=this;
          axios.post(Common.API+'getTradeUser?current='+vm.pagination.currentPage+'&size='+vm.pagination.pageSize,vm.form).then(function (res) {
              vm.pagination.totals=res.data.total;
              vm.dataList=res.data.records;
            })
            .catch(function (error) {
              console.log(error);
            });
        },
        showDetail(row){
          var vm=this
          this.available=row.available;
          this.showCheckDialog=true;
          axios.post(Common.API+'getEnterpriseInfoById?enterpriseId='+row.enterpriseid).then(function (res) {
            vm.showForm=res.data;
            vm.showForm.userid=row.id;
          })
        },
        approved(available){
          var vm=this
          axios.post(Common.API+'approvedUser',{
            user:{
              enterpriseid:vm.showForm.enterpriseId,
              available:available
            },
            message:{
              userid:vm.showForm.userid,
              content:'您的资质:'+available,
              status:'未阅'
            },
          }).then(function (res) {
            if(res.data.code==200){
              vm.$message({
                message: res.data.msg,
                type: 'success'
              });
              vm.showCheckDialog=false;
              vm.getData();
            }else {
              vm.$message.error(res.data.msg);
            }
          })
        },
        download(path){
          window.open("http://localhost:8071/download?fileName="+1);
        },
      }

    }
</script>
<style scoped>
  body{
    height: 100%;
  }
  h1, h2 {
    font-weight: normal;
  }
  ul {
    list-style-type: none;
    padding: 0;
  }
  li {
    display: inline-block;
    margin: 0 10px;
  }
  a {
    color: #42b983;
  }
  .title{
    margin-left: 30px;
    line-height: 50px;
    width: 100%;
    font-size: 30px;
    height: 50px;
  }
  .AuditRegister{
    width: 100%;
    height:100px;
  }
  .AuditRegister .head{
    padding-top:20px;
    width: 80%;
    margin: 0 auto;
  }
  .AuditRegister .demo-form-block{
    display: block;
  }
  .AuditRegister .content{
    width: 80%;
    margin: 0 auto;
  }

  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }


  .showInput{
    height: 28px;
    line-height: 28px;
    -webkit-appearance: none;
    background-color: #FFF;
    background-image: none;
    border-radius: 4px;
    border: 1px solid #DCDFE6;
    border-top-color: rgb(220, 223, 230);
    border-right-color: rgb(220, 223, 230);
    border-bottom-color: rgb(220, 223, 230);
    border-left-color: rgb(220, 223, 230);
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    color: #606266;
    display: inline-block;
    font-size: inherit;

    outline: 0;
    padding: 0 15px;
    -webkit-transition: border-color .2s cubic-bezier(.645,.045,.355,1);
    transition: border-color .2s cubic-bezier(.645,.045,.355,1);
    width: 100%;
  }



</style>
